package com.fitzpatrickit.robotics.hexaped;

import lejos.nxt.Button;
import lejos.nxt.ButtonListener;
import lejos.robotics.subsumption.Behavior;

public class TerminateBehaviour implements Behavior, ButtonListener {
	
	private boolean buttonPressed = false;
	
	private final HexapedMoveController hexapedMoveController;
	
	public TerminateBehaviour(HexapedMoveController controller) {
		Button.ENTER.addButtonListener(this);
		this.hexapedMoveController = controller;
	}

	public void action() {
		this.hexapedMoveController.reset();
		System.exit(0);
	}

	public void suppress() {
		// this is not suppressable
	}

	public boolean takeControl() {
		return this.buttonPressed;
	}

	public void buttonPressed(Button arg0) {
		// nothing to do
	}

	public void buttonReleased(Button arg0) {
		this.buttonPressed = true;
	}

}
